package com.lb.bs.client.repository;

import com.lb.bs.client.beans.GroupInfo;
import com.lb.bs.client.beans.LBGrayIPBean;
import com.lb.bs.client.beans.LBGrayItemBean;
import com.lb.bs.client.beans.LBItemBean;
import com.lb.bs.client.callback.UpdateCallBackService;
import com.lb.bs.client.constants.Constants;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * program: LB-BS-Client
 * author: bsworld.xie
 * create: 2019-11-27 11:27
 * description:
 */
public class StoreCenter {

    public static final String GRAY_PREFIX = Constants.GRAY_PREFIX;

    public static final String GRAY_IP = Constants.GRAY_IP;


    private String localAddress;


    private Map<String, LBItemBean> itemKeyMap = new ConcurrentHashMap<>();


    private Map<String, List<UpdateCallBackService>> itemKeyCallBackMap = new LinkedHashMap<>();


    private Map<String, GroupInfo> groupInfoMap = new HashMap<>();

    /**
     * 灰度地址集合
     *
     * key:灰度key /gray + /groupName
     *
     * value:机器IP地址
     */
    private Map<String, LBGrayIPBean> grayIPKeyMap = new HashMap<>();

    private Map<String, LBGrayItemBean> grayItemKeyMap = new HashMap<>();

    private Map<String, String> groupLogPathMap = new HashMap<>();


    public static class Singleton {
        private static StoreCenter storeCenter = new StoreCenter();

        public static StoreCenter getStoreCenter() {
            return storeCenter;
        }
    }


    private StoreCenter() {

    }



    public static StoreCenter getInstance() {
        return Singleton.getStoreCenter();
    }

    public Map<String, LBItemBean> getItemKeyMap() {
        return itemKeyMap;
    }

    public void setItemKeyMap(Map<String, LBItemBean> itemKeyMap) {
        this.itemKeyMap = itemKeyMap;
    }



    public Map<String, List<UpdateCallBackService>> getItemKeyCallBackMap() {
        return itemKeyCallBackMap;
    }

    public void setItemKeyCallBackMap(Map<String, List<UpdateCallBackService>> itemKeyCallBackMap) {
        this.itemKeyCallBackMap = itemKeyCallBackMap;
    }

    public Map<String, GroupInfo> getGroupInfoMap() {
        return groupInfoMap;
    }

    public void setGroupInfoMap(Map<String, GroupInfo> groupInfoMap) {
        this.groupInfoMap = groupInfoMap;
    }

    public Map<String, LBGrayIPBean> getGrayIPKeyMap() {
        return grayIPKeyMap;
    }

    public void setGrayIPKeyMap(Map<String, LBGrayIPBean> grayIPKeyMap) {
        this.grayIPKeyMap = grayIPKeyMap;
    }

    public Map<String, LBGrayItemBean> getGrayItemKeyMap() {
        return grayItemKeyMap;
    }

    public void setGrayItemKeyMap(Map<String, LBGrayItemBean> grayItemKeyMap) {
        this.grayItemKeyMap = grayItemKeyMap;
    }

    public String getLocalAddress() {
        return localAddress;
    }

    public void setLocalAddress(String localAddress) {
        this.localAddress = localAddress;
    }

    public Map<String, String> getGroupLogPathMap() {
        return groupLogPathMap;
    }

    public void setGroupLogPathMap(Map<String, String> groupLogPathMap) {
        this.groupLogPathMap = groupLogPathMap;
    }
}
